package functii;
import operatori.Cat;
import operatori.Produs;

public class Tangenta extends Functie {

	public double calcul(double aux1)
	{
		return Math.tan(aux1);
	}
	// returneaza valoarea argumentului functiei
	
	public static double Calcul(double aux1)
	{
		return Math.tan(aux1);
	}
		
		/*if (getFStang() == null)
			System.exit(1);
		return calcul(getFStang().calcul()); */
	
	//returneaza un string reprezentand derivarea functiei
	
	public String derivare()
	{
		if (getFStang() == null)
			System.exit(1);
		return Produs.concatTermens(getFStang().derivare(),
				Cat.concatTermens("1",
						Produs.concatTermens(Cos.concatTermens

(getFStang().toString()),
								Cos.concatTermens

(getFStang().toString()))));
	}
	// calculeaza valoarea derivatei intr-un anumit punct
	 
	public double calculDerivata()
	{
		if (getFStang() == null)
			System.exit(1);
		return Produs.Calcul(getFStang().calculDerivata(), Cat.Calcul(1,  
				Produs.Calcul(Cos.Calcul(getFStang().calculDerivata()),
								Cos.Calcul(getFStang().calcul()))));
	}
	public String toString()
	{
		if (getFStang() == null)
			System.exit(1);
		return concatTermeni(getFStang().toString());
	}
	public static String concatTermens(String aux1)
	{
		String aux;
		int nrP;
		nrP = aux1.charAt(0) == '(' ? 0 : 2;
		aux = "tg";
		if (nrP != 0) aux += "(";
		aux += aux1;
		if (nrP != 0) aux += ")";
		return aux;
	}
	public String concatTermeni(String aux1)
	{
		String aux;
		int nrP;
		nrP = aux1.charAt(0) == '(' ? 0 : 2;
		aux = "tg";
		if (nrP != 0) aux += "(";
		aux += aux1;
		if (nrP != 0) aux += ")";
		return aux;
	}
	public double calculeazaValoare() {
		return this.calcul();
	}
}

